#!/usr/bin/python3
import pandas as pd

from detl import TjDataToPD
import indcal
from taijiapi import GetTaijiHq
import matplotlib.pyplot as plt

if __name__ == "__main__":
    req = GetTaijiHq('晶澳科技', date='20231110', num=250)
    indcal.InitCal()
    if req is not None:
        df = TjDataToPD(req)
        print(df.columns)
        rsi = indcal.CalIndicator("Rsi", df)
        mav = indcal.CalIndicator("MaVol", df)
        arbr = indcal.CalIndicator('ArBr', df)
        macd = indcal.CalIndicator('MaCd', df)
        rsi.plot(kind='line')
        other = pd.DataFrame(
            data={'RSI': rsi, 'MAVOL': mav, 'AR': arbr['AR'], 'BR': arbr['BR'], 'MACD': macd['MACD'],
                  'close': df.close},
            index=rsi.index).dropna()
        plt.show()
        print(other.index)
        print(other.columns)
        other.to_csv('macd2.csv')
